using System.Data;
using System.Linq;

namespace Home.Site.Models.DataLayer
{
    public class TagRepository : ITagRepository
    {
        readonly PromikeDBEntities context = new PromikeDBEntities();

        public IQueryable<TagName> All
        {
            get { return context.TagNames; }
        }

        public TagName Find(string id)
        {
            return context.TagNames.Find(id);
        }

        public void Insert(TagName tagName)
        {
            context.TagNames.Add(tagName);
            context.SaveChanges();
        }

        public void Update(TagName tagName)
        {
            context.Entry(tagName).State = EntityState.Modified;
            context.SaveChanges();
        }

        public void Delete(TagName tagName)
        {
            context.TagNames.Remove(tagName);
            context.SaveChanges();
        }
    }
}